package org.mat.ipaas.ucenter.bff.admin.modules.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.api.system.SysUserOnlineRestAPI;
import org.mat.ipaas.ucenter.service.dto.system.vo.SysUserOnlineVODTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 在线用户
 * @Author: chenli
 * @Date: 2020-06-07
 * @Version: V1.0
 */
@RestController
@RequestMapping("/sys/online")
@Slf4j
public class SysUserOnlineController {

    @Autowired
    private SysUserOnlineRestAPI sysUserOnlineRestAPI;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public MatApiResponse<Page<SysUserOnlineVODTO>> list(@RequestParam(name="username", required=false) String username,
                                                         @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                         @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        MatApiResponse<Page<SysUserOnlineVODTO>> matApiResponse = sysUserOnlineRestAPI.list(username, pageNo, pageSize);
        return matApiResponse;
    }

    /**
     * 强退用户
     */
    @RequestMapping(value = "/forceLogout",method = RequestMethod.POST)
    public MatApiResponse<Object> forceLogout(@RequestBody SysUserOnlineVODTO online) {
        MatApiResponse<Object> matApiResponse = sysUserOnlineRestAPI.forceLogout(online);
        return matApiResponse;
    }
}
